package com.sfd.test.controller;

import com.sfd.core.entity.Order;
import com.sfd.core.module.Result;
import com.sfd.test.service.ManyUserService;
import com.sfd.test.service.OrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author haden
 * @date 2022/8/8 18:15
 **/
@RequestMapping("/order")
@RestController
public class OrderController {
    @Resource
    private OrderService orderService;
    @Resource
    private ManyUserService manyUserService;

    @GetMapping("create")
    public Result<String> create() {
        try {
            orderService.create();
        } catch (Exception e) {
            return Result.busError(e.getMessage());
        }
        return Result.success();
    }

    @GetMapping("get")
    public Result<List<Order>> get() {
        try {
            return Result.success(orderService.list());
        } catch (Exception e) {
            return Result.busError(e.getMessage());
        }
    }


}
